<template>
  <el-container>
    <el-aside width="200px">
      <SideMenu></SideMenu>
    </el-aside>
    <el-container>
      <el-header>
        <strong>VueAdmin后台管理系统</strong>
        <div class="header-avatar">
          <el-avatar size="large" :src="userInfo.imgSrc"></el-avatar>
          <el-dropdown>
            <span class="el-dropdown-link">
              {{ userInfo.username }}<i class="el-icon-arrow-down el-icon--right"></i>
            </span>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item>
                <router-link to="/userCenter">个人中心</router-link>
              </el-dropdown-item>
              <el-dropdown-item @click.native="logout">退出</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
          <el-link icon="el-icon-view" href="https://www.baidu.com/" target="_blank" type="warning">点击百度</el-link>
          <el-link icon="el-icon-view" href="https://www.bing.com/" target="_blank" type="success">点击bing</el-link>
        </div>
      </el-header>
      <el-main style="" id="main">
        <tabs></tabs>
        <div style="margin: 0 15px">
          <router-view></router-view>
        </div>
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
import SideMenu from "@/views/inc/SideMenu";
import Tabs from "@/views/inc/Tabs";
export default {
  name: "Home",
  components:{
    SideMenu,
    Tabs
  },
  data() {
    return {
      userInfo: {
        id:'',
        imgSrc: '',
        username: ''
      }
    }
  },
  created() {
    this.getUserInfo();
  },
  methods:{
    getUserInfo(){
      let userInfo=this;
      this.$axios.get("/sys/userInfo").then(function (result) {
        userInfo.userInfo=result.data.data;
      })
    },
    logout(){
      let flag=this;
      this.$axios.post("/logout").then(function (result) {
        localStorage.clear();
        sessionStorage.clear();
        flag.$store.commit("resetState");
        flag.$router.push("/login");
      })
    }
  }
}
</script>

<style>
.header-avatar {
  float: right;
  width: 310px;
  display: flex;
  justify-content: space-around;
  align-items: center;
}

.el-dropdown-link {
  cursor: pointer;
  color: #409EFF;
}

.el-icon-arrow-down {
  font-size: 12px;
}

.el-header, .el-footer {
  background-color: #B3C0D1;
  color: #333;
  text-align: center;
  line-height: 60px;
}
#main{
  background-color: #E9EEF3;
  color: #333;
  height: 92vh;
  padding:0 0 0 0;
}
.el-aside {
  background-color: #D3DCE6;
  color: #333;
  text-align: center;
  line-height: 200px;
}

a{
  text-decoration: none;
}
body > .el-container {
  margin-bottom: 40px;
}
</style>